import { request } from '@/service/request';
import { SysDept } from "@/views/system/dept/index";


export function fetchDeptTree() {
  return request({
    url: '/sys/dept/tree',
    method: 'GET',
  });
}

export function fetchDept(id: Common.IdType) {
  return request({
    url: '/sys/dept/' + id,
    method: 'GET',
  });
}

export function fetchUpdateDept(data: SysDept) {
  return request({
    url: '/sys/dept',
    data: data,
    method: 'PUT',
  });
}

export function fetchAddDept(data: SysDept) {
  return request({
    url: '/sys/dept',
    data: data,
    method: 'POST',
  });
}

export function fetchDeleteDept(ids: Common.IdType[]) {
  // 假设 ids 是一个单个 ID 的数组，如果需要传递多个 ID，可能需要调整服务器端接口来接收数组或逗号分隔的字符串
  return request({
    url: '/sys/dept/' + ids.join(','),
    method: 'DELETE',
  });
}
